<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <style type="text/css">
        .box2 {
            float: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>统计分析
            <small>会员占比</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员占比</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container" >
        <!--性别饼图-->
        <div class="box2" style="width: 50%;">
            <div id="chart1" style="height:650px;"></div>
        </div>
        <!--年龄段饼图-->
        <div class="box2" style="width:50%;">
            <div id="chart2" style="height:650px;"></div>
        </div>

    </div>
</div>
</body>

<!-- 引入组件库 -->
    <script src="../js/vue.js"></script>
    <script src="../js/axios-0.18.0.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../plugins/echarts/echarts.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script type="text/javascript">
        var vue = new Vue({
            el: "#app",
            data: {
                backendUrl: "http://localhost:82",
                time:null
            },
            methods: {},
            created(){

            }
        });

        // 基于准备好的dom，初始化echarts实例
        var myChart1 = echarts.init(document.getElementById('chart1'));
        var myChart2 = echarts.init(document.getElementById('chart2'));


        axios.defaults.withCredentials = true;/*如果要使用安全框架,必须携带cookie*/
        axios.get("http://localhost:82/report/getMemberScaleReport.do").then((response) => { /*成功时执行的回调*/
            console.log("response");
            console.log(response.data.data);

            //获取当前时间
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var day = date.getDate();
            if (month < 10) {
                month = "0" + month;
            }
            if (day < 10) {
                day = "0" + day;
            }
            var nowDate = year + "-" + month + "-" + day;

            /*性别统计饼图*/
            myChart1.setOption(option = {
                title: {
                    text: '会员男女性别比例',
                    subtext: nowDate + ' 统计',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: response.data.data.genderScaleMap.genders,
                },
                series: [
                    {
                        name: '会员男女性别比例',
                        type: 'pie',
                        radius: '55%',
                        center: ['50%', '60%'],
                        data: response.data.data.genderScaleMap.genderCount,
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            });

            /*年龄统计饼图*/
            myChart2.setOption(option = {
                title : {
                    text: '会员年龄比例',
                    subtext: nowDate + ' 统计',
                    x:'center'
                },
                tooltip : {
                    trigger: 'item',
                    formatter: "{a} <br/>{b} : {c} ({d}%)"
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: response.data.data.ageScaleMap.ageList
                },
                series : [
                    {
                        name: '会员年龄比例',
                        type: 'pie',
                        radius : '55%',
                        center: ['50%', '60%'],
                        data:response.data.data.ageScaleMap.countMapList,
                        itemStyle: {
                            emphasis: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            });


        }).catch((error) => { /*异常时执行的回调*/
            console.log(error);
        });

    </script>
</html>

<!--


-->